<include file="Public/min-header" />
<div class="wrapper">
	<style type="text/css">
		.navbar{margin-bottom: 0px;}
		#fenlei_box{border: 1px solid #3297ff;position: absolute;width:380px;height:250px;overflow-y: auto; z-index:9999;background:#fff;display:none;margin-left: 38px;}
		#fenlei_box li{list-style: none;color:#3297ff;text-align:center;margin-left:-40px;line-height: 32px;cursor: pointer;padding-left:20px;padding-right:20px;}
	</style>
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<div class="box-header">
						<nav class="navbar navbar-default">
							<div class="collapse navbar-collapse">
								<form class="navbar-form form-inline"  method="get">
									<div class="form-group">添加：
										<input type="text" id="quyu" value="" class="input-sm" style="width: 380px;text-align: center;" oninput="quyu_sousuo($(this))" autocomplete="off" title="" placeholder="输入添加区域">
										<ul id="fenlei_box" rel="{$goods.goods_id}">
									</div>
								</form>
							</div>
						</nav>
					</div>
					<div class="box-body">
						<div class="row">
							<div class="col-sm-12">
								<table id="list-table" class="table table-bordered table-striped dataTable">
									<thead>
									<tr role="row">
										<th class="text-center">ID</th>
										<th class="text-center">区域名称</th>
										<th style="text-align: center;">操作</th>
									</tr>
									</thead>
									<tbody>
									<foreach name="quyu_stops" item="vo" key="k" >
										<tr class="text-center" role="row">
											<td class="text-center" style="padding:0;">{$vo.fenbu_id}</td>
											<td class="text-center" style="padding:0;">{$vo.fenbu_name}</td>
											<td class="text-center" style="padding:0;">
												<a class="btn btn-danger" id="shanchu" rel="{$vo.fenbu_id}">删除</a>
											</td>
										</tr>
									</foreach>
									</tbody>
									<tfoot>

									</tfoot>
								</table>
							</div>
						</div>
						<div class="row">
							<div class="col-sm-6 text-left">
								<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
							</div>
							<div class="col-sm-6 text-right">{$page}</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".box-body #bianji").click(function(){
				var myrel=$(this).attr('rel');
				var myrul='/Admin/Goods/goods_bianji/goods_id/'+myrel;//+myrel;
				layer.open({
					type: 2,
					title:'编辑限制区域',
					shadeClose: true, //点击遮罩关闭
					skin: 'layui-layer-rim', //加上边框
					area: ['920px', '620px'], //宽高
					content: myrul
				})
			});

			$("body").on("click", function() {
				$('body #fenlei_box').hide(100);
			});

			$("body #fenlei_box").on("click","li", function() {
			    var goods_ids = "{:I("goods_id")}"
				var ids=$(this).attr('rel'),text=$(this).attr('rev')
				$.post("/Admin/Goods/goods_bianji_quyus",
						{
							action:'add',
							goods_id:goods_ids,
							value:ids
						},
						function(data,status){
							setTimeout(function(){
								location.reload();
							},1000);
						});

			});

			$(".box-body #shanchu").click(function(){
			    var goods_ids = "{:I("goods_id")}"
				var del_id=$(this).attr('rel');
				$.post("/Admin/goods/goods_bianji_quyus",
						{
							action:'del',
							goods_id:goods_ids,
				            del_id:del_id
			},
				function(data,status){
					location.reload();
				});
			});
		});

		function quyu_sousuo(obj)
		{
			var value = obj.val();
			$.ajax({
				url:"/Admin/store/quyu_sousuo?key="+value,
				success: function(data){
					if(data!=''){
						obj.parent().find('#fenlei_box').show(100);
						obj.parent().find('#fenlei_box').html(data);
					}else{
						obj.parent().find('#fenlei_box').hide(100);
					}
				}
			});
		}
	</script>
</div>
</body>
</html>   
